<?php

namespace App\Jobs;

use App\Models\Comment;
use App\Models\Note;
use App\Models\Qh_Question;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class QuestionDeleteHelper8Job implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected int $questionId;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($questionId)
    {
        $this->questionId = $questionId;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        // 删除评论和笔记
        Comment::where('questionId', $this->questionId)->delete();
        Note::where('questionId', $this->questionId)->delete();
    }
}
